package com.leetcode.August;

/**
 * @Description: 160. 相交链表
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-23 22:38
 */
public class LC160相交链表 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if (headA == null || headB == null) return null;
        ListNode a = headA, b = headB;
        while (a != b) {
            a = a == null ? headB : a.next;
            b = b == null ? headA : b.next;
        }
        return b;
    }
}
